<template>
  <div class="home">
    <!-- 标题 -->
    <!-- <van-nav-bar title="标题" /> -->
        <!--搜索框 -->
    <van-search @input="SearchQuery" shape="round" v-model="value" placeholder="请输入搜索关键词" />
    <!-- 刷新组件 -->
    <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
    <!-- 轮播图 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item>1</van-swipe-item>
      <van-swipe-item>2</van-swipe-item>
      <van-swipe-item>3</van-swipe-item>
      <van-swipe-item>4</van-swipe-item>
    </van-swipe>
    <!-- Navbar导航栏 -->
    <List></List>
    <!-- 分类 -->
    <div class="cardList">
      <div>
        <span>组局</span>
        <span>分类·排行·详解</span>
        <img src="" alt="">
      </div>
      <div>
        <span>协会</span>
        <span>分类·排行·详解</span>
        <img src="" alt="">
      </div>
      <div>
        <span>场地</span>
        <span>分类·排行·详解</span>
        <img src="" alt="">
      </div>
      <div>
        <span>市锦赛</span>
        <span>分类·排行·详解</span>
        <img src="" alt="">
      </div>
    </div>
<!-- 频道展示区 -->
  <van-card
  num="2"
  price="2.00"
  desc="描述信息"
  title="阳光广场"
  thumb="https://img01.yzcdn.cn/vant/ipad.jpeg"
>
  <template #tags>
    <van-tag plain type="danger">标签</van-tag>
  </template>
  <template #footer>
    <van-button size="mini">预约</van-button>
    <van-button size="mini">按钮</van-button>
  </template>
</van-card>
  <van-card
  num="2"
  price="2.00"
  desc="描述信息"
  title="森林公园"
  thumb="https://img01.yzcdn.cn/vant/ipad.jpeg"
>
  <template #tags>
    <van-tag plain type="danger">标签</van-tag>
  </template>
  <template #footer>
    <van-button size="mini">预约</van-button>
    <van-button size="mini">按钮</van-button>
  </template>
</van-card>
  <van-card
  num="2"
  price="2.00"
  desc="描述信息"
  title="体育馆"
  thumb="https://img01.yzcdn.cn/vant/ipad.jpeg"
>
  <template #tags>
    <van-tag plain type="danger">标签</van-tag>
  </template>
  <template #footer>
    <van-button size="mini">预约</van-button>
    <van-button size="mini">按钮</van-button>
  </template>
</van-card>
  <van-card
  num="2"
  price="2.00"
  desc="描述信息"
  title="室内活动室"
  thumb="https://img01.yzcdn.cn/vant/ipad.jpeg"
>
  <template #tags>
    <van-tag plain type="danger">标签</van-tag>
  </template>
  <template #footer>
    <van-button size="mini">预约</van-button>
    <van-button size="mini">按钮</van-button>
  </template>
</van-card>
    </van-pull-refresh>
  </div>
</template>

<script>
// import axios from 'axios'
import List from '../components/PartList.vue'
import { Toast } from 'vant'
export default {
  name: 'HomeView',
  data () {
    return {
      value: '',
      count: 0,
      isLoading: false,
      // 计时器
      timer: '',
      searchList: []
    }
  },
  components: {
    List
  },
  methods: {
    onRefresh () {
      setTimeout(() => {
        Toast('刷新成功')
        this.isLoading = false
        this.count++
      }, 1000)
    },
    // 输入类容变化查询
    SearchQuery (value) {
      if (this.timer !== '') {
        clearTimeout(this.timer)
        this.timer = ''
      }
      this.timer = setTimeout(() => {
        // 发送请求，获取相关链接信息
        console.log('发起搜索')
      }, 400)
    }
  }
}
</script>
<style lang="less" scoped>
.cardList {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  height: 13rem;
  background-color: #f6f6f6;
  div {
    position: relative;
    width: 48%;
    height: 46%;
    background-color: #ffffff;
    border-radius: 5%;
    span:nth-child(1) {
      display: inline-block;
      position: absolute;
      width: 4rem;
      height: 1rem;
      font-size: 0.9rem;
      font-weight: 700;
      margin-top: 2rem;
      margin-left: 1rem;
    }
    span:nth-child(2) {
      display: inline-block;
      position: absolute;
      width: 9rem;
      height: 1rem;
      margin-top: 3.5rem;
      margin-left: 1rem;
      font-size: 0.7rem;
      color: #bdbcbc;
    }
    img {
      display: inline-block;
      position: absolute;
      right: 0.8rem;
      top: 1.5rem;
      width: 3rem;
      height: 3rem;
      background-color: red;
    }
  }
}
.home {
  overflow-y: auto;
  width: 100%;
  height: 40rem;
  background-color: #f7f7f7;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #39a9ed;
}
.van-swipe {
  margin-top: 3.36rem;
}
.van-search {
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  opacity: 0.7;
}
.home::-webkit-scrollbar {
  display: none;
}
</style>
